package com.etc.controller;

import com.etc.layui.Layui;
import com.etc.pojo.SightComment;
import com.etc.pojo.SightDetail;
import com.etc.service.SightCommentService;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@RequestMapping("/SightCommentController")
public class SightCommentController {


    @Autowired
    SightCommentService service;

    @ResponseBody
    @RequestMapping("/queryAllSightComment")
    public List<SightComment> queryAllSightComment() {
        List<SightComment> list = service.selectAllSightComment();
        return list;
    }


    @RequestMapping("/delSightComment")
    public int delSightComment(int commentId) {
        return service.delSightComment(commentId);

    }


    @RequestMapping("/getSightComment")
    @ResponseBody
    public Layui getSightComment(@RequestParam(value = "pageNum",defaultValue = "1") int pageNum,
                                @RequestParam(value = "pageSize",defaultValue = "3") int pageSize){
        System.out.println("我是分页");
        PageInfo<SightComment> pageInfo = service.getAllSightCommentByPage(pageNum,pageSize);
        return Layui.data(pageInfo.getTotal(),pageInfo.getList());
    }

}
